#pragma once
#ifndef camera_hpp
#define camera_hpp

#include <SDL/SDL.h>
#include <math.h>

class camera{
//private:
public:
 float pos[3];
 float rot[3];
//public:
 camera(){
  pos[0]= 0;//2500;
  pos[1]= 0;//500;
  pos[2]= 0;//2000;
  rot[0]= 30;
  rot[1]= 45;
  rot[2]= 0;
 }

 int isvisible(float min[3], float max[3]){
  return 1;
 }

 void handle_mouse_motion(int x_rel, int y_rel){
  rot[0]+= (float)y_rel/10;
  if(rot[0]< -90){
   rot[0]= -90;
  }
  if(rot[0]> 90){
   rot[0]= 90;
  }
  rot[1]+= (float)x_rel/10;
 }

 void handle_key_events(unsigned char keys[]){
/*
*elmozdulas merteke
*/
  float r= 20;
  float xrotrad= (rot[0]/180*M_PI);
  float yrotrad= (rot[1]/180*M_PI);
/*
*billentyuk kezelese
*/
  if(keys[SDLK_w]){
   pos[0]+= (float)(r*sin(yrotrad)*cos(xrotrad));
   pos[2]+= -(float)(r*cos(yrotrad)*cos(xrotrad));
   pos[1]+= -(float)r*sin(xrotrad);
  }

  if(keys[SDLK_s]){
   pos[0]+= -(float)(r*sin(yrotrad)*cos(xrotrad));
   pos[2]+= (float)(r*cos(yrotrad)*cos(xrotrad));
   pos[1]+= (float)r*sin(xrotrad);
  }

  if(keys[SDLK_a]== 1){
   pos[0]-= (float)(r*cos(yrotrad));
   pos[2]-= (float)(r*sin(yrotrad));
  }

  if(keys[SDLK_d]== 1){
   pos[0]+= (float)(r*cos(yrotrad));
   pos[2]+= (float)(r*sin(yrotrad));
  }
 }

};

#endif
